/*  
 * Copyright 2007 MBARI 
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License. 
 */
package org.mbari.timeline.piccolo;

import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

import org.mbari.timeline.DateUtil;

import junit.framework.TestCase;

import com.domainlanguage.time.TimePoint;

/** 
 * @author Andrew Chase
 */
public class TestDateUtil extends TestCase {
	public void testAnsiDateConversion() throws Exception{
		TimePoint time = DateUtil.ansiStandardDateStringToDate("20070424-12:01:01");
		Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
		calendar.set(2007, 3, 24, 12, 1, 1); //months are offset by 1
		Date expectedDate = calendar.getTime();
		long difference = Math.abs(expectedDate.getTime() - time.asJavaUtilDate().getTime());
		assertTrue("difference is " + difference, difference < 1000); //within 1 second of each other
	}
}
